<?php
date_default_timezone_set('Asia/Bangkok');
// Dinh nghia duong dan den thu vien cua Zend
set_include_path('./library/'
        . PATH_SEPARATOR . './application/models' . PATH_SEPARATOR . './application/');
// Goi class Zend_Load	
require_once './library/Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);

// Start log for application.
$_writer = new Zend_Log_Writer_Stream('./application/error.log');
$logger = new Zend_Log($_writer);
// Zend_Loader::registerAutoload();

Zend_Session::start();

//Dinh nghia hang so dung chung 
$App = new Zend_Config_Ini('./config/config.ini', 'App');
$registry = Zend_Registry::getInstance();
$registry->set('App', $App);

// Load configuration
$config = new Zend_Config_Ini('./config/config.ini', 'dbmysql');
// $config = new Zend_Config_Ini('./application/config.ini', 'dbmssql');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);

// Setup database.
$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('dbAdapter', $db);
$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory(array(
    'default' => './application/controllers',
    'admin'    => './application/admin/controllers',
    'system'    => './application/system/controllers',
    'module'    => './application/module/controllers',
));
$frontController->setDefaultModule('default');
$frontController->dispatch();
?>
